#ifndef NET_DEFS_H
#define NET_DEFS_H

#include <stdbool.h>
#include <stdint.h>

#define MAX_PROT 32

typedef enum {
    PROTO_INVALID = 0,
    PROTO_ICMP = 1,
    PROTO_IGMP = 2,
    PROTO_TCP = 6,
    PROTO_EGP = 8,
    PROTO_IGP = 9,
    PROTO_UDP = 17,
    PROTO_IPv6 = 41,
    PROTO_GRE = 47,
    PROTO_ESP = 50,
    PROTO_ICMPv6 = 51,
    PROTO_EIGRP = 88,
    PROTO_OSPF = 89,
    PROTO_VRRP = 112,
    PROTO_L2TP = 115
} PROTO_TYPE;

typedef enum {
    PORT_INVALID = 0,
    PORT_FTP = 20,
    PORT_SSH = 22,
    PORT_TELNET = 23,
    PORT_SMTP = 25,
    PORT_DNS = 53,
    PORT_TFTP = 69,
    PORT_HTTP = 80,
    PORT_POP3 = 110,
    PORT_HTTPS = 443,
    PORT_UDP = 500
} PORT_NUM;

typedef enum { ACTION_INVALID = 0, ACTION_DROP = 1, ACTION_ACCEPT = 2, ACTION_REJECT = 3 } ACTION_TYPE;

typedef struct {
    char* src;
    char* dst;
    uint32_t sport[MAX_PROT];
    uint32_t dport[MAX_PROT];
    uint32_t proto;
    uint32_t action;
    int bitmap;
} pkt_metadata_t;

typedef struct pkt_md_node {
    uint32_t rule_id;
    pkt_metadata_t* pkt_md;
    struct pkt_md_node* next;
} pkt_md_node_t;

typedef pkt_md_node_t pkt_md_list;

typedef struct {
    uint32_t key;
    char* val;
} kv_t;

#define NELM_KV(x) (sizeof(x) / sizeof(kv_t))

void print_pkt_md(pkt_metadata_t* pkt_md, const char* reason);
uint32_t get_action(char* action);
const char* get_action_str(ACTION_TYPE action);
uint32_t get_proto(char* proto);

#endif // NET_DEFS_H